﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ImportMFGsFromFile.CApImportMFGsAnalytics
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using Tecnomatix.DnSoftwareAnalyticsServices;


namespace DnProcessSimulateCommands.ImportMFGsFromFile;

internal class CApImportMFGsAnalytics : IDisposable
{
  private static CApImportMFGsAnalytics m_instance;
  private DateTime m_startSessionTime;
  private string m_sessionName;

  public CApImportMFGsAnalytics()
  {
    this.m_startSessionTime = DateTime.Now;
    this.m_sessionName = "Session_" + this.m_startSessionTime.ToString("yyyyMMddHHmmss");
  }

  public static void Start()
  {
    if (CApImportMFGsAnalytics.m_instance != null)
    {
      CApImportMFGsAnalytics.m_instance.Dispose();
      CApImportMFGsAnalytics.m_instance = (CApImportMFGsAnalytics) null;
    }
    if (!TxSoftwareAnalyticsServices.isLoggerEnabled())
      return;
    CApImportMFGsAnalytics.m_instance = new CApImportMFGsAnalytics();
  }

  public static void End()
  {
    if (CApImportMFGsAnalytics.m_instance == null)
      return;
    CApImportMFGsAnalytics.m_instance.Dispose();
    CApImportMFGsAnalytics.m_instance = (CApImportMFGsAnalytics) null;
  }

  public static void LogImportMfgFile(string filePath, int mfgCount)
  {
    if (CApImportMFGsAnalytics.m_instance == null)
      return;
    using (TxSoftwareAnalyticsServicesMsg message = CApImportMFGsAnalytics.m_instance.CreateMessage())
    {
      message.addProperty("File Name Hashed", filePath.GetHashCode().ToString());
      message.addNumericProperty("Amount of MFGs", (double) mfgCount);
      CApImportMFGsAnalytics.m_instance.LogMessage(message);
    }
  }

  public TxSoftwareAnalyticsServicesMsg CreateMessage()
  {
    TxSoftwareAnalyticsServicesMsg message = new TxSoftwareAnalyticsServicesMsg();
    message.Type = "Import MFG";
    message.addProperty("Import MFG Session", this.m_sessionName);
    return message;
  }

  public void LogMessage(TxSoftwareAnalyticsServicesMsg message)
  {
    if (message == null)
      return;
    TxSoftwareAnalyticsServices.log(message);
  }

  public void Dispose()
  {
  }
}
